<div class="admin_nrtop">
    <div class="ad_search" style="font-size: 24px;">
       首页轮播展示(965*380)
    </div>
</div>
<div  class="biaoge">
    <div class="biaotbody">
        <table>
            <tr>
                <th class="li3">
                    <div class="lileft">&nbsp;</div>
                </th>
                <th class="li9">
                    <div class="lileft"><span>名称</span></div>
                </th>
                <th class="li15">
                    <div class="lileft"><span>图片</span></div>
                </th>
                <th class="li5">
                    <div class="lileft"><span>排序</span></div>
                </th>
                <th class="li5">
                    <div class="lileft"><span>是否显示</span></div>
                </th>
                <th class="li5">
                    <div class="lileft">操作</div>
                </th>
            </tr>
        </table>
    </div>
     <div class="table">
         <table>

             <?php if($this->banner){ foreach ($this->banner as $Item) { ?> 
                 <tr id="tr_<?php echo $Item->id;?>">
                     <td class="li3">&nbsp;</td>
                     <td class="li9">
                         <div class="lileft">
                            <?php echo $Item->Title;?>
                         </div>
                     </td>
                     <td class="li15">
                         <div class="lileft yonghu">
                             <img src="<?php echo $Item->picurl;?>" width="50">                           
                        </div>
                     </td>

                     <td class="li5">
                         <div class="lileft">
                             <input type="text" id="order_<?php echo $Item->Order;?>" name="order[]" value="<?php echo $Item->Order;?>" onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" style="width:50px;"/>
                        </div>
                     </td>
                     <td class="li5">
                         <div class="lileft">
                             <?php if($Item->Status==1) echo '显示';else echo '不显示';?>
                         </div>
                     </td>
                     <td class="li5">
                         <div class="">
                        <a class="xlnavxq" href="javascript:void(0)" name="<?php echo $Item->Id;?>">编辑</a>
                         </div>
                     </td>
                 </tr>
             <?php } }else{
                echo "<font size='4' color='red'>暂无数据</font>";
                } ?>   
         </table>
     </div>
 </div>
<div class="toolbar">
    <div class="qunx">
        <ul>
            <li><a class="anvbotton" href="javascript:void(0)" id="addNavigation" name="addNavigation"><span>添加</span></a></li>
        </ul>
    </div>
</div>
<style>
    #add_table{
        width: 600px;
        font-size: 16px;
        padding: 5px;
    }
    #add_table *{
        font-size: 14px;
        padding: 5px;
    }
</style>
<div class="tanchuang" style="display:none;">
    <div class="nui-msgbox">
        <div class="nui-msgbox-hd" id="wayProblem">添加</div>
        <a class="nui-msgbox-close" title="关闭"><b></b></a>
    </div>
    <div class="wenti_box" id="problemComm">
            <div style="margin-left:10px;margin-top: 15px;margin-bottom: 5px;">
                <table id="add_table">
                    <tr>
                        <td align="right">标题：</td>
                        <td><input type="text" id="title" name="title" value="" style="width:300px;"/></td>
                    </tr>
                    <tr>
                       <td align="right">图片：</td>
                        <td> <input type='text' value='' id='imgpath' name='imgpath'>
                            <span id="pic_url"><input type="file" id="pict_url" name="pict_url" value="" />
                        <input type='hidden' name='picpath' value='/banner/'/><span id="showimg"></span></span>
                         </td>
                    </tr>
                    <tr>                        
                        <td align="right">链接：</td>
                        <td><input type="text" id="url" name="url" value="" style="width:300px;"/></td>
                    </tr>
                    <tr>
                       <td align="right">是否显示：</td>
                        <td><select id="status" name="status">
                                <option value="1">显示</option>
                                <option value="0">不显示</option>
                            </select></td>
                    </tr>
                    <tr>                        
                        <td align="right">排序：</td>
                        <td><input type="text" id="order" name="order" value="0" /></td>
                    </tr>
                   
                    <tr>
                        <td align="center"  colspan="2">
                            <input type="hidden" id="Id" name="Id" value="" />                            
                            <input type="button" id="navigationAdd" naem="navigationAdd" value="添加" style="background-color: #F60;width: 50px;height: 36px;color: white;font-size: 16px;border-radius:8px;"/>
                            &nbsp;&nbsp;<input type="button" id="refo" naem="refo" value="返回" style="background-color: #1668A4;width: 50px;height: 36px;color: white;font-size: 16px;border-radius:8px;"/>
                        </td>
                    </tr>
                </table>
            </div>
    </div>
</div>
<div class="houtai_overlay" style="display:none;"></div>
<script>
    $("#addNavigation").click(function(){
        $(".houtai_overlay").show();
        $(".tanchuang").show();
    });
    $(".nui-msgbox-close").click(function(){
        $(".houtai_overlay").hide();
        $(".tanchuang").hide();
    })
    $(".xlnavxq").click(function(){
       var id = $(this).attr("name");
       $.post("/admini/banner/detail",{"id":id},function(date){
           if(date.sj == 1){
                $("#title").val(date.title);
                $("#url").val(date.url);               
                $("#order").val(date.order);               
                $("#status").find("option[value='"+date.status+"']").attr("selected",true);
                $("#imgpath").val(date.picurl);
                $("#Id").val(id);
                $("#navigationAdd").val("修改");
                $(".houtai_overlay").show();
                $(".tanchuang").show();
           }else{
               alert("出现未知错误，请刷新在试。");
           }
       });
    });

    $("#refo").click(function(){
        $(".houtai_overlay").hide();
        $(".tanchuang").hide();
    });
    $("#navigationAdd").click(function(){ 
        var Id = $("#Id").val();        
        var title = $("#title").val();      
        var order = $("#order").val();        
        var status = $("#status").val();
        var picurl = $("#imgpath").val();
        var url = $("#url").val();
        if(title == ""){
            alert("导航名称不能为空");
            return ;
        }
        $.post('/admini/banner/addbanner', {'id':Id,'title':title,'picurl':picurl,'url':url,"order":order,"status":status}, function(sj){
             if(sj == 1){
                 alert("添加成功！");
                 location.href = "/admini/banner/index/";
             }else{
                 alert("出现未知错误");
             }
        }, 'json');
       
    });
</script>

 <script type="text/javascript">
$(function () {
    var showimg = $('#showimg');
    $("#pic_url").wrap("<form id='myupload' style='display:inline;' action='/admini/ajax/upimg2' method='post' enctype='multipart/form-data'></form>");
    $("#pic_url").change(function(){
        $("#myupload").ajaxSubmit({
            dataType:  'json',                     
            success: function(data) {              
                var img = "http://cdn.uuch.com/banner/"+data.pic;
                $('#imgpath').val(img);
                showimg.html("上传成功");
            },
            error:function(xhr){
                showimg.html("上传失败");
            }
        });
    });
});
</script>